<template>
    <div>
        <div class="ui-title">
            <div class="ui-title-back" onclick="window.hideWebview()"></div>
            <div class="ui-title-text">易学书箱</div>
            <div class="ui-title-btn-block">
                <!--<span class="ui-title-btn icon xzr xzr-ico-liebiao " onclick="location.reload();"></span>-->
            </div>
        </div>
        <div class="body">
            <div class="book-block" style="padding-top:0">
                <div class="search xzr xzr-ico-sousuo">
                    <input type="text" class="search-input" ref="search" placeholder="输入书名" @input="search">
                </div>
                <div class="pub-empty"  v-if="list.length<1"> <span class="icon xzr xzr-ico-ku"></span>没有搜索到书籍</div>
                <div class="book-list" v-for="v in list" @click="bookdetail({info:v})">
                    <!--<img :src="v.img" class="book-img"/>-->
                    <div class="book-cover">
                        <div class="book-cover-title">{{v.title}}</div>
                        <div class="book-cover-hr"></div>
                    </div>
                    <div class="book-title">{{v.title}}</div>
                </div>
            </div>
        </div>
    </div>

</template>

<script>
    var booklistStr=""
    export default {
        data: function () {
            return {
                list:[]
            }
        },
        methods: {
            bookdetail:function (data) {
                var options={};
                options.page='bookinfo';
                options.hash=data;
                window.openWebview(options);
            },
          /*  detail:function(data){
                window.alert(JSON.stringify(data))
                //plus.storage.setItem('currentBook',JSON.stringify(data));
                window.openWebview({page:'bookdetail',hash:data});
            },*/
            init:function () {
                var list=JSON.parse(booklistStr),tmp=[];
                for(var i=0;i<list.length;i++){
                    tmp.push(list[i]);
                }
                this.list=tmp;
            },
            search:function(){
                var list=JSON.parse(booklistStr),tmp=[];
                for(var i=0;i<list.length;i++){
                    if(list[i].title.indexOf(this.$refs.search.value)>-1){
                        tmp.push(list[i]);
                    }
                }
                this.list=tmp;
            }
        },
        created: function () {
            booklistStr=JSON.stringify(HASH.booklist);
            this.init();
        }
    }



</script>

